home *** CD-ROM | disk | FTP | other *** search
- 5 dv=peek(186):ifdv<8thendv=8
- 8 poke53371,0
- 10 dimm%(5,5,27)
- 20 dime(5),e$(5),f(8),h(5)
- 30 dims(88),s1%(120,5),s2%(120,88),t%(120)
- 40 dimg%(50,2),g$(50)
- 50 k$="[150] [144] [150] [144] [150] [144] [150] [144] [146]":l$="[144] [150] [144] [150] [144] [150] [144] [150] [144][146]"
- 60 m$="[150] [144] [150] [144] [150] [144] [150] [144] [146]":n$="[144] [150] [144] [150] [144] [150] [144] [150] [144][146]"
- 70 gosub1510:fori=1to5:readh(i):next
- 80 print"-[199]enerating matrix of moves."
- 90 fori=1to5:m%(1,i,0)=0
- 100 ife(i)-10*int(e(i)/10+.01)<3ore(i)>78then120
- 110 m%(1,i,0)=m%(1,i,0)+1:m%(1,i,m%(1,i,0))=e(i)+8
- 120 ife(i)-10*int(e(i)/10+.01)=1ore(i)>68then140
- 130 m%(1,i,0)=m%(1,i,0)+1:m%(1,i,m%(1,i,0))=e(i)+19
- 140 ife(i)-10*int(e(i)/10+.01)=8ore(i)>67then160
- 150 m%(1,i,0)=m%(1,i,0)+1:m%(1,i,m%(1,i,0))=e(i)+21
- 160 ife(i)-10*int(e(i)/10+.01)>6ore(i)>76then180
- 170 m%(1,i,0)=m%(1,i,0)+1:m%(1,i,m%(1,i,0))=e(i)+12
- 180 ife(i)-10*int(e(i)/10+.01)>6ore(i)<21then200
- 190 m%(1,i,0)=m%(1,i,0)+1:m%(1,i,m%(1,i,0))=e(i)-8
- 200 ife(i)-10*int(e(i)/10+.01)=8ore(i)<31then220
- 210 m%(1,i,0)=m%(1,i,0)+1:m%(1,i,m%(1,i,0))=e(i)-19
- 220 ife(i)-10*int(e(i)/10+.01)=1ore(i)<32then240
- 230 m%(1,i,0)=m%(1,i,0)+1:m%(1,i,m%(1,i,0))=e(i)-21
- 240 ife(i)-10*int(e(i)/10+.01)<3ore(i)<23then260
- 250 m%(1,i,0)=m%(1,i,0)+1:m%(1,i,m%(1,i,0))=e(i)-12
- 260 next
- 270 fori=1to5:m%(2,i,0)=0
- 280 l1=e(i)-10*int(e(i)/10+.01):l2=int(e(i)/10+.01):ifl1=1orl2=8then310
- 290 l3=l1-1:if8-l2<l3thenl3=8-l2
- 300 forj=1tol3:m%(2,i,0)=m%(2,i,0)+1:m%(2,i,m%(2,i,0))=e(i)+9*j:next
- 310 l1=e(i)-10*int(e(i)/10+.01):l2=int(e(i)/10+.01):ifl1=8orl2=8then340
- 320 l3=8-l1:if8-l2<l3thenl3=8-l2
- 330 forj=1tol3:m%(2,i,0)=m%(2,i,0)+1:m%(2,i,m%(2,i,0))=e(i)+11*j:next
- 340 l1=e(i)-10*int(e(i)/10+.01):l2=int(e(i)/10+.01):ifl1=8orl2=1then370
- 350 l3=8-l1:ifl2-1<l3thenl3=l2-1
- 360 forj=1tol3:m%(2,i,0)=m%(2,i,0)+1:m%(2,i,m%(2,i,0))=e(i)-9*j:next
- 370 l1=e(i)-10*int(e(i)/10+.01):l2=int(e(i)/10+.01):ifl1=1orl2=1then400
- 380 l3=l1-1:ifl2-1<l3thenl3=l2-1
- 390 forj=1tol3:m%(2,i,0)=m%(2,i,0)+1:m%(2,i,m%(2,i,0))=e(i)-11*j:next
- 400 next
- 410 fori=1to5:m%(3,i,0)=0
- 420 l2=int(e(i)/10+.01):ifl2=8then440
- 430 forj=1to8-l2:m%(3,i,0)=m%(3,i,0)+1:m%(3,i,m%(3,i,0))=e(i)+10*j:next
- 440 l1=e(i)-10*int(e(i)/10+.01):ifl1=8then460
- 450 forj=1to8-l1:m%(3,i,0)=m%(3,i,0)+1:m%(3,i,m%(3,i,0))=e(i)+j:next
- 460 l2=int(e(i)/10+.01):ifl2=1then480
- 470 forj=1tol2-1:m%(3,i,0)=m%(3,i,0)+1:m%(3,i,m%(3,i,0))=e(i)-10*j:next
- 480 l1=e(i)-10*int(e(i)/10+.01):ifl1=1then500
- 490 forj=1tol1-1:m%(3,i,0)=m%(3,i,0)+1:m%(3,i,m%(3,i,0))=e(i)-j:next
- 500 next
- 510 fori=1to5:m%(4,i,0)=m%(2,i,0)+m%(3,i,0)
- 520 forj=1tom%(2,i,0):m%(4,i,j)=m%(2,i,j):next
- 530 forj=1tom%(3,i,0):m%(4,i,m%(2,i,0)+j)=m%(3,i,j):next
- 540 next
- 550 fori=1to5:m%(5,i,0)=0
- 560 l1=e(i)-10*int(e(i)/10+.01):l2=int(e(i)/10+.01):ifl1=1orl2=8then580
- 570 m%(5,i,0)=m%(5,i,0)+1:m%(5,i,m%(5,i,0))=e(i)+9
- 580 l1=e(i)-10*int(e(i)/10+.01):l2=int(e(i)/10+.01):ifl1=8orl2=8then600
- 590 m%(5,i,0)=m%(5,i,0)+1:m%(5,i,m%(5,i,0))=e(i)+11
- 600 l1=e(i)-10*int(e(i)/10+.01):l2=int(e(i)/10+.01):ifl1=8orl2=1then620
- 610 m%(5,i,0)=m%(5,i,0)+1:m%(5,i,m%(5,i,0))=e(i)-9
- 620 l1=e(i)-10*int(e(i)/10+.01):l2=int(e(i)/10+.01):ifl1=1orl2=1then640
- 630 m%(5,i,0)=m%(5,i,0)+1:m%(5,i,m%(5,i,0))=e(i)-11
- 640 l2=int(e(i)/10+.01):ifl2=8then660
- 650 m%(5,i,0)=m%(5,i,0)+1:m%(5,i,m%(5,i,0))=e(i)+10
- 660 l1=e(i)-10*int(e(i)/10+.01):ifl1=8then680
- 670 m%(5,i,0)=m%(5,i,0)+1:m%(5,i,m%(5,i,0))=e(i)+1
- 680 l2=int(e(i)/10+.01):ifl2=1then700
- 690 m%(5,i,0)=m%(5,i,0)+1:m%(5,i,m%(5,i,0))=e(i)-10
- 700 l1=e(i)-10*int(e(i)/10+.01):ifl1=1then720
- 710 m%(5,i,0)=m%(5,i,0)+1:m%(5,i,m%(5,i,0))=e(i)-1
- 720 next
- 730 print"[145]-[199]enerating matrix of permutations."
- 740 s1%(0,0)=0:forl5=1to5
- 750 forl4=1to5:ifl4=l5then850
- 760 forl3=1to5:ifl3=l4orl3=l5then840
- 770 forl2=1to5:ifl2=l3orl2=l4orl2=l5then830
- 780 l1=15-l5-l4-l3-l2
- 790 s1%(0,0)=s1%(0,0)+1
- 800 f(1)=l1:f(2)=l2:f(3)=l3:f(4)=l4:f(5)=l5
- 810 fori=1to5:forj=1to5:iff(j)=ithens1%(s1%(0,0),i)=j:j=5
- 820 next:next
- 830 nextl2
- 840 nextl3
- 850 nextl4
- 860 nextl5
- 870 print"[145]-[199]enerating matrix of combined hits."
- 880 fori=1to120
- 890 forj=1to5
- 900 fork=1tom%(j,s1%(i,j),0)
- 910 s2%(i,m%(j,s1%(i,j),k))=s2%(i,m%(j,s1%(i,j),k))+1
- 920 next:next:next
- 930 print"[145]-[199]enerating table of legal boards. ":f(6)=0:f(7)=0:f(8)=0
- 940 ifg%(0,1)=0thent%(0)=120:fori=1to120:t%(i)=i:next:f(6)=120:f(7)=120:goto1010
- 950 fori=1tot%(0)
- 960 ifs2%(t%(i),g%(g%(0,1),1))<>g%(g%(0,1),2)then980
- 970 f(6)=f(6)+1:t%(f(6))=t%(i):f(8)=f(7):f(7)=t%(i)
- 980 next:t%(0)=f(6)
- 990 ift%(0)=0then2640
- 1000 ift%(0)=1then1420
- 1010 print"[145]-[199]enerating matrix to compare squares."
- 1020 fori=11to88:s(i)=0:next
- 1030 fori=11to81step10:forj=0to7:fork=0to5:f(k)=0:next
- 1040 fork=1tot%(0):f(s2%(t%(k),i+j))=f(s2%(t%(k),i+j))+1:next
- 1050 fork=0to5:s(i+j)=s(i+j)+abs(f(k)-t%(0)/6):next
- 1060 nextj,i
- 1070 if se=1 then1270
- 1080 fori=1to5:s(e(i))=500:next
- 1090 if t%(0)>2 then1270
- 1100 fl=0:fori=11to81step10:forj=0to7
- 1110 if s2%(f(7),i+j)=s2%(f(8),i+j) then1150
- 1120 fork=1to5:ife(k)=i+j thenk=9
- 1130 next:if k>9 then1150
- 1140 fl=1:j=7:i=81
- 1150 nextj,i:if fl=1 then1270
- 1160 print"[147][199]uessing at complete arrangement:"
- 1170 print"[211]quare ?s:";g%(0,1);" [208]osition ?s: 1":gosub2500
- 1180 print" [203]night on ";e$(s1%(f(8),1));","
- 1190 print" [194]ishop on ";e$(s1%(f(8),2));","
- 1200 print" [210]ook on ";e$(s1%(f(8),3));","
- 1210 print" [209]ueen on ";e$(s1%(f(8),4));", and"
- 1220 print" [203]ing on ";e$(s1%(f(8),5));".":print
- 1230 print"[201]s this right (y/n)? ";:poke198,0
- 1240 geta$:if ((a$<>"y") and (a$<>"n")) then goto1240
- 1250 if (a$="y") then print"[217]es.":goto1500
- 1260 g%(0,1)=g%(0,1)+1:g%(g%(0,1),1)=f(8)+1000:print"[206]o.":goto1420
- 1270 print"[145]-[211]electing best scoring square. "
- 1280 if (g%(0,1)<1) then goto1300
- 1290 fori=1tog%(0,1):s(g%(i,1))=999:next
- 1300 g%(0,1)=g%(0,1)+1:g%(g%(0,1),1)=11
- 1310 fori=11to81step10:forj=0to7
- 1320 if (s(i+j)<s(g%(g%(0,1),1))) then g%(g%(0,1),1)=i+j
- 1330 nextj,i
- 1340 print"[147]";t%(0);"permutations are possible.":print
- 1350 print"[199]uess";g%(0,1);"is square ";
- 1360 a$=str$(g%(g%(0,1),1)):b$=chr$((asc(right$(a$,1)))+16):printb$;
- 1370 c$=chr$(asc(right$(left$(a$,2),1))):printc$;".":g$(g%(0,1))=b$+c$
- 1380 gosub2420
- 1390 print"[200]ow many men attack this square?";:poke198,0
- 1400 geta$:if ((a$<"0") or (a$>"5")) then goto1400
- 1410 g%(g%(0,1),2)=val(a$):printval(a$):print:goto930
- 1420 print"[147][211]olution found after";g%(0,1);"guess";
- 1430 ifg%(0,1)<>1thenprint"es";
- 1440 print".":gosub2570
- 1450 print"[203]night on square ";e$(s1%(f(7),1));","
- 1460 print"[194]ishop on square ";e$(s1%(f(7),2));","
- 1470 print"[210]ook on square ";e$(s1%(f(7),3));","
- 1480 print"[209]ueen on square ";e$(s1%(f(7),4));", and"
- 1490 print"[203]ing on square ";e$(s1%(f(7),5));"."
- 1500 goto2740
- 1510 poke53280,13:poke53281,13:print"[147]";chr$(14);"[144] [212]o [211]olve [205]ystery [211]quare [195]hess":print
- 1520 printtab(7);"[208]rogrammed by [198]loyd [203]irk":print
- 1530 print" [212]his program is to solve the problem"
- 1540 print"generated by the [205]ystery [211]quare [195]hess"
- 1550 print"program or by a person. [198]ive squares"
- 1560 print"are chosen on a chessboard and their"
- 1570 print"coordinates given to this program. [212]he"
- 1580 print"program will place a [203]night, [194]ishop,"
- 1590 print"[210]ook, [209]ueen, and [203]ing on the five"
- 1600 print"mystery squares by asking only 2 types"
- 1610 print"of questions:"
- 1620 print" 1. [215]hen the pieces are properly set up,";
- 1630 print" how many attack [212][200][201][211] square?"
- 1640 print" 2. [201]s this the correct position?"
- 1650 print" [193]s the piece names suggest, these have";
- 1660 print"the attacking abilities of their chess"
- 1670 print"counterparts, except that they can"
- 1680 print"attack [212][200][210][207][213][199][200] any other piece. [197]ach"
- 1690 print"man attacks as though it is the only"
- 1700 print"man on the board."
- 1710 printtab(5);"<-[208]ress space-bar for more.->":poke198,0
- 1712 fori=217to242:pokei,peek(i)or128:next
- 1720 geta$:ifa$=""then1720
- 1730 print"[147] [212]he [193]ttack [208]atterns of the [208]ieces":print
- 1740 print"[206] = [203]night [194] = [194]ishop [209] = [209]ueen"
- 1750 print"[210] = [210]ook [203] = [203]ing x = [193]ttacked [211]quare":print
- 1760 print" [150]x[144] [150] [144] [150] [144] [150] [144] [146] [150] [144] [150] [144]x[150] [144] [150] [144] [146] ";
- 1770 print" [150] [144] [150] [144]x[150] [144] [150] [144]x[146] ";m$
- 1780 print" [144] [150]x[144] [150] [144] [150] [144] [150]x[146] [144] [150] [144] [150]x[144] [150] [144] [150] [146][144] ";
- 1790 print" [144]x[150] [144] [150]x[144] [150] [144]x[150] [146] [144] [150] [144] [150]x[144] [150]x[144] [150] [146][144] ";
- 1800 print" [150] [144] [150]x[144] [150] [144] [150]x[144] [146] [150] [144] [150] [144]x[150] [144] [150] [144] [146] ";
- 1810 print" [150] [144]x[150] [144]x[150] [144]x[150] [144] [146] [150] [144] [150]x[144] [150] [144] [150]x[144] [146] ";
- 1820 print" [144] [150] [144] [150]x[144] [150]x[144] [150] [146] [144]x[150]x[144]x[150][210][144]x[150]x[144]x[150]x[146][144] ";
- 1830 print" [144] [150] [144]x[150]x[144]x[150] [144] [150] [146] [144] [150] [144] [150] [144][206][150] [144] [150] [146][144] ";
- 1840 print" [150] [144] [150] [144] [150][194][144] [150] [144] [146] [150] [144] [150] [144]x[150] [144] [150] [144] [146] ";
- 1850 print" [150]x[144]x[150]x[144][209][150]x[144]x[150]x[144]x[146] [150] [144] [150]x[144] [150] [144] [150]x[144] [146] ";
- 1860 print" [144] [150] [144] [150]x[144] [150]x[144] [150] [146] [144] [150] [144] [150]x[144] [150] [144] [150] [146][144] ";
- 1870 print" [144] [150] [144]x[150]x[144]x[150] [144] [150] [146] [144] [150] [144] [150]x[144] [150]x[144] [150] [146][144] ";
- 1880 print" [150] [144] [150]x[144] [150] [144] [150]x[144] [146] [150] [144] [150] [144]x[150] [144] [150] [144] [146] ";
- 1890 print" [150] [144]x[150] [144]x[150] [144]x[150] [144] [146] ";m$
- 1900 print" [144] [150]x[144] [150] [144] [150] [144] [150]x[146] [144] [150] [144] [150]x[144] [150] [144] [150] [146][144] ";
- 1910 print" [144]x[150] [144] [150]x[144] [150] [144]x[150] [146] ";n$:print
- 1920 print" ";m$;" [194] attacks diagonally."
- 1930 print" ";n$;" [210] vertically & horizontally."
- 1940 print" [150] [144]x[150]x[144]x[150] [144] [150] [144] [146] [209] combines [194] and [210] attacks."
- 1950 print" [144] [150]x[144][203][150]x[144] [150] [144] [150] [144][146] [206] 2 over and 1 across."
- 1960 print" [150] [144]x[150]x[144]x[150] [144] [150] [144] [146] [203] attacks nearest squares."
- 1970 print" ";n$
- 1980 print" ";m$;" [206]o man attacks its own square";
- 1990 print" ";n$;" [206]o attack crosses board edge."
- 2000 printtab(5);"<-[208]ress space-bar for more.->":poke198,0
- 2002 fori=217to242:pokei,peek(i)or128:next
- 2010 geta$:ifa$=""then2010
- 2020 print"[147]";tab(5);"[197]ntering the [205]ystery [211]quares":print
- 2030 print" [212]ype the [204][197][212][212][197][210] of the column and then";
- 2040 print"type the [206][213][205][194][197][210] of the row containing"
- 2050 print"the mystery square. [210]epeat for all five."
- 2060 printtab(14);"8 ";m$:printtab(14);"7 ";n$:printtab(14);"6 ";m$:printtab(14);"5 ";n$
- 2070 printtab(14);"4 ";m$:printtab(14);"3 ";n$:printtab(14);"2 ";m$:printtab(14);"1 ";n$
- 2080 printtab(16);"abcdefgh":print
- 2090 fori=1to7:print" ":next:print"[145][145][145][145][145][145][145]";
- 2100 fori=1to5
- 2110 print"[205]ystery square";i;"is on: [157][157]";:poke198,0
- 2112 forz=217to242:pokez,peek(z)or128:next
- 2120 geta$:ifa$=""then2120
- 2130 ifa$<"a"ora$>"h"then2120
- 2140 printa$;:e$(i)=a$:e(i)=asc(a$)-64
- 2150 geta$:ifa$=""then2150
- 2160 ifa$<"1"ora$>"8"then2150
- 2170 printa$:e$(i)=e$(i)+a$:e(i)=e(i)+val(a$)*10:
- 2180 ifi=1then2210
- 2190 fl=0:forj=1toi-1:ife(j)=e(i)thenfl=1:j=i
- 2200 next:iffl=1thenprint"[145]";:goto2110
- 2210 poke1599-val(a$)*40+asc(left$(e$(i),1))-64,170:next
- 2220 print:print"[201]s this correct (y/n)? ";:poke198,0
- 2230 geta$:ifa$<>"y"anda$<>"n"then2230
- 2240 ifa$="n"ora$="[206]"thenprint"[206]o.":goto2020
- 2250 ifa$<>"y"anda$<>"[217]"then2230
- 2260 print"[217]es."
- 2270 print"[147]";" [193]sking about the [205]ystery [211]quares":print
- 2280 print" [212]he original version of this game did"
- 2290 print"not allow a person to ask how many times";
- 2300 print"the mystery squares themselves were"
- 2310 print"attacked. [201] found that allowing such"
- 2320 print"questions led to an elegant solution."
- 2330 print"[217]ou may choose which version the"
- 2340 print"computer is to play.":print
- 2350 print"[211]elect one: ([208]ress 1 or 2)"
- 2360 print"1. [195][193][206] ask # attacks on mystery squares.";
- 2370 print"2. [195]an [206][207][212] query mystery squares.":print:poke198,0
- 2372 fori=217to242:pokei,peek(i)or128:next
- 2380 geta$:if ((a$<>"1") and (a$<>"2")) then goto2380
- 2390 se=val(a$):print"[195]omputer [195][193][206] ";:if (se=1) then2410
- 2400 print"[206][207][212] ";
- 2410 print"query mystery squares.":print:return
- 2420 print:printtab(10);"8 ";k$:printtab(12);k$:printtab(10);"7 ";l$:printtab(12);l$
- 2430 printtab(10);"6 ";k$:printtab(12);k$:printtab(10);"5 ";l$:printtab(12);l$
- 2440 printtab(10);"4 ";k$:printtab(12);k$:printtab(10);"3 ";l$:printtab(12);l$
- 2450 printtab(10);"2 ";k$:printtab(12);k$:printtab(10);"1 ";l$:printtab(12);l$
- 2460 printtab(12);"a b c d e f g h":print
- 2470 fori=1to5:poke1834-val(right$(e$(i),1))*80+(asc(left$(e$(i),1))-64)*2,170:next
- 2480 poke1875-val(c$)*80+(asc(b$)-64)*2,191
- 2490 return
- 2500 print:printtab(14);"8 ";m$:printtab(14);"7 ";n$:printtab(14);"6 ";m$:printtab(14);"5 ";n$
- 2510 printtab(14);"4 ";m$:printtab(14);"3 ";n$:printtab(14);"2 ";m$:printtab(14);"1 ";n$
- 2520 printtab(16);"abcdefgh":print
- 2530 fori=1to5
- 2540 poke1479-val(right$(e$(s1%(f(8),i)),1))*40+asc(left$(e$(s1%(f(8),i)),1))-64,h(i)
- 2550 next
- 2560 return
- 2570 print:printtab(14);"8 ";m$:printtab(14);"7 ";n$:printtab(14);"6 ";m$:printtab(14);"5 ";n$
- 2580 printtab(14);"4 ";m$:printtab(14);"3 ";n$:printtab(14);"2 ";m$:printtab(14);"1 ";n$
- 2590 printtab(16);"abcdefgh":print
- 2600 fori=1to5
- 2610 poke1439-val(right$(e$(s1%(f(7),i)),1))*40+asc(left$(e$(s1%(f(7),i)),1))-64,h(i)
- 2620 next
- 2630 return
- 2640 print"[147][206]o solution found; please check answers."
- 2650 printtab(10);"8 ";k$:printtab(12);k$:printtab(10);"7 ";l$:printtab(12);l$
- 2660 printtab(10);"6 ";k$:printtab(12);k$:printtab(10);"5 ";l$:printtab(12);l$
- 2670 printtab(10);"4 ";k$:printtab(12);k$:printtab(10);"3 ";l$:printtab(12);l$
- 2680 printtab(10);"2 ";k$:printtab(12);k$:printtab(10);"1 ";l$:printtab(12);l$
- 2690 printtab(12);"a b c d e f g h":print
- 2700 fori=1to5:poke1754-val(right$(e$(i),1))*80+(asc(left$(e$(i),1))-64)*2,170:next
- 2710 fori=1tog%(0,1)
- 2720 poke1795-val(right$(g$(i),1))*80+(asc(left$(g$(i),1))-64)*2,g%(i,2)+176
- 2730 next
- 2740 goto3000
- 2750 data206,194,210,209,203
- 3000 print" [144]([193][144])nother puzzle
- 3010 [153]" ((NULL)stop)(NULL)atnstr$(NULL)(NULL)atn(NULL)
- 3030 poke198,0
- 3040 geta$:ifa$<>"a"anda$<>"l"then3040
- 3050 ifa$="l"then40000
- 3070 run
- 10000 d=peek(186):n$="b.solve myschess":open15,d,15,"s0:"+n$:close15:saven$,d:end
- 40000 fori=8to29:poke820+i,i:next:ifdv>8anddv<30thenpoke828,dv:poke820+dv,8
- 40010 a$="presenter":gosub40030:a$="hello connect":gosub40030
- 40020 print"[147]":poke53272,23:poke186,8:poke2048,0:poke44,8:poke43,1:end
- 40030 forj=8to29:i=peek(820+j):ifi=14thennext
- 40040 close2:open2,i,2:close2:ifstthen40060
- 40050 close15:open15,i,15,"r0:"+a$+"="+a$:input#15,er:close15:ifer=63then40070
- 40060 next:return
- 40070 a$="hello connect":q$=chr$(34):poke646,peek(53281):print"[147]":poke53272,23
- 40080 print"[147]p[207]2048,0:p[207]44,8:p[207]43,1:p[207]56,160:p[207]55,0:clr:l[207]"q$a$q$","i
- 40090 print"run:":poke631,13:poke632,13:poke198,2:end
-